package com.pz.cloud.framework.business.workflow.model;

import com.pz.cloud.framework.base.constants.WorkflowContants;
import lombok.Data;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 工作流bean
 * @author 3hmzz
 */
@Data
public class WorkflowModel  {
    /**
     * 审批意见
     */
    protected String opinion;
    /**
     * 审批结果
     */
    protected String result;

    private String lineId;//选择路径id

    protected String handlerId;//指定待办人，用于开启流程的时候提交给下一步处理人

    protected String operation;


    private String relatedId; //关联业务记录主键
    private String relatedTable; //关联业务记录表

    private String processKey;//流程定义key

    private String processBindId;//流程绑定id

    private Map<String,Object> taskField;//任务字段

    protected Map<String,Object> taskHandler;//任务处理人

    private String callback;//回调类

    private Integer returnFlag = 0;//是否退回 0否 1是
    /**
     * 文件标题
     */
    private String title;
    /**
     * 文件号
     */
    private String number;

    protected VariableMap<String,Object> variable;//流程变量


    public static class VariableMap<key,val> extends HashMap<String,Object> {

        public VariableMap(){
            super();
        }

        private List<String> assigneeList;
        private String assignee;

        public List<String> getAssigneeList() {
            if(super.get("assigneeList") !=null)
                return (List<String>)super.get("assigneeList");
            else
                return assigneeList;
        }

        public String getAssignee() {
            if(super.get("assignee") !=null)
                return (String) super.get("assignee");
            else
               return assignee;
        }

        public void setAssignee(String assignee) {
            super.put("assignee",assignee);
            this.assignee = assignee;
        }
        public void setAssignee(List<String> assignee) {
            super.put("assignee",assignee);
        }
        public <T>T getAssingee() {
            return (T)super.get("assignee");
        }

        public void setAssigneeList(List<String> assigneeList) {
            super.put("assigneeList",assigneeList);
            this.assigneeList = assigneeList;
        }
    }

    public VariableMap<String, Object> getVariable() {
        if(variable==null){
            variable = new WorkflowModel.VariableMap<>();
        }
        return variable;
    }


//    /**
//     * 是否第一次提交 流程开启
//     * @return
//     */
//    public Boolean isStart(){
//        return WorkflowContants.WORKFLOW_START.equals(this.getOperation());
//    }
//    /**
//     * 是否提交
//     * @return
//     */
//    public Boolean isSubmit(){
//        return WorkflowContants.WORKFLOW_SUBMIT.equals(this.getOperation());
//    }

}
